home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / CD32 / CD32_Support / examples / SA_Examples / graphics / wpixel / wpixel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-17  |  35.0 KB  |  1,295 lines

  1. /*
  2.     wpixel.c -- Mark Dolecki
  3.     Program to test WritePixelArray8 on new hardware
  4. */
  5.  
  6. /* Includes */
  7. #include <exec/types.h>
  8. #include <exec/memory.h>
  9. #include <graphics/gfx.h>
  10. #include <graphics/gfxbase.h>
  11. #include <graphics/gfxmacros.h>
  12. #include <graphics/rastport.h>
  13. #include <graphics/displayinfo.h>
  14. #include <intuition/intuition.h>
  15. #include <intuition/classes.h>
  16. #include <intuition/classusr.h>
  17. #include <intuition/gadgetclass.h>
  18. #include <intuition/intuitionbase.h>
  19. #include <intuition/screens.h>
  20. #include <libraries/asl.h>
  21. #include <libraries/gadtools.h>
  22. #include <clib/alib_protos.h>
  23. #include <clib/alib_stdio_protos.h>
  24. #include <clib/asl_protos.h>
  25. #include <clib/dos_protos.h>
  26. #include <clib/exec_protos.h>
  27. #include <clib/gadtools_protos.h>
  28. #include <clib/graphics_protos.h>
  29. #include <clib/intuition_protos.h>
  30. #include <clib/layers_protos.h>
  31. #include <stddef.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34.  
  35. #include <pragmas/exec_pragmas.h>
  36. #include <pragmas/intuition_pragmas.h>
  37. #include <pragmas/gadtools_pragmas.h>
  38. #include <pragmas/graphics_pragmas.h>
  39.  
  40. /* Defines */
  41. #define DEBUG TRUE
  42. #define NUMWINS 10
  43. #define MAXDEPTH 8
  44. #define NUMREFRESH 3
  45. #define RECTWIDTH 10
  46. #define RECTHEIGHT 10
  47.  
  48. #define GD_Depth                               0
  49. #define GD_depth1                              1
  50. #define GD_depth2                              2
  51. #define GD_depth3                              3
  52. #define GD_depth4                              4
  53. #define GD_depth5                              5
  54. #define GD_depth6                              6
  55. #define GD_depth7                              7
  56. #define GD_depth8                              8
  57. #define GD_layered                             9
  58. #define GD_nonlayered                          10
  59. #define GD_simple                              11
  60. #define GD_smart                               12
  61. #define GD_super                               13
  62. #define GD_lay                                 14
  63. #define GD_refresh                             15
  64. #define GD_mask                                16
  65. #define GD_ranmask                             17
  66. #define GD_negmask                             18
  67. #define GD_nummasks                            19
  68.  
  69. #define GDX_Depth                              0
  70. #define GDX_depth1                             1
  71. #define GDX_depth2                             2
  72. #define GDX_depth3                             3
  73. #define GDX_depth4                             4
  74. #define GDX_depth5                             5
  75. #define GDX_depth6                             6
  76. #define GDX_depth7                             7
  77. #define GDX_depth8                             8
  78. #define GDX_layered                            9
  79. #define GDX_nonlayered                         10
  80. #define GDX_simple                             11
  81. #define GDX_smart                              12
  82. #define GDX_super                              13
  83. #define GDX_lay                                14
  84. #define GDX_refresh                            15
  85. #define GDX_mask                               16
  86. #define GDX_ranmask                            17
  87. #define GDX_negmask                            18
  88. #define GDX_nummasks                           19
  89.  
  90.  /* Globals */
  91. extern struct ExecBase *SysBase;
  92. struct GadToolsBase *GadToolsBase = NULL;
  93. struct IntuitionBase *IntuitionBase = NULL;
  94. struct GfxBase *GfxBase = NULL;
  95. struct LayersBase *LayersBase = NULL;
  96.  
  97. struct Screen *TestScreen = NULL;
  98. struct Window *TestWins[NUMWINS];
  99. struct RastPort *RPs[NUMWINS];
  100. struct BitMap *TempBMs[NUMWINS];
  101. struct RastPort *TempRPs[NUMWINS];
  102.  
  103. UBYTE *vers = "$VER: wpixel 2.1 (12-May-1993) by Mark Dolecki";
  104.  
  105. /* struct Window *TestWindow1 = NULL;
  106. struct Window *TestWindow2 = NULL;
  107. struct RastPort *rp1 = NULL;
  108. struct RastPort *rp2 = NULL;
  109. struct BitMap   *tempbm1 = NULL;
  110. struct BitMap   *tempbm2 = NULL;
  111. struct RastPort *temprp1 = NULL;
  112. struct RastPort *temprp2 = NULL; */
  113.  
  114. UBYTE *pixelarray = NULL;      /* [((((RECTWIDTH+15)>>4)<<4)*(RECTHEIGHT + 1))]; */
  115. long pixelarraywidth = 0L;
  116. long pixelarrayheight = 0L;
  117. struct ScreenModeRequester *smr;
  118. ULONG PixCheckSum = 0;
  119. int NumTests = 0;
  120. int numbytes = 0;
  121. int depth = 0;
  122. BOOL deptharray[8] = { TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE };
  123. BOOL layerarray[2] = { TRUE,TRUE };
  124. BOOL refresharray[3] = { TRUE,TRUE,TRUE };
  125. BOOL maskarray[2] = { TRUE,TRUE };
  126. int nummasks = 3;
  127. int rectwidth = 10;
  128. int rectheight = 10;
  129.  
  130. struct Screen        *Scr = NULL;
  131. APTR                  VisualInfo = NULL;
  132. struct Window        *WPWnd = NULL;
  133. struct Gadget        *WPGList = NULL;
  134. struct Gadget        *WPGadgets[20];
  135. UWORD                 OffX = 0, OffY = 0;
  136. UWORD                 WPLeft = 1;
  137. UWORD                 WPTop = 11;
  138. UWORD                 WPWidth = 286;
  139. UWORD                 WPHeight = 147;
  140. UBYTE                *WPWdt = (UBYTE *)"WPixel";
  141. struct TextAttr      *Font = NULL, Attr;
  142. UWORD                 FontX = 0, FontY = 0;
  143. UWORD                 OffX, OffY;
  144.  
  145. /* Function Protos */
  146. void dPrintf(char *s);
  147. void unclipWindow(struct Window *);
  148. struct Region *clipWindowToBorders(struct Window *win);
  149. struct Region *clipWindow(struct Window *,LONG,LONG,LONG,LONG);
  150. int SetupScreen( void );
  151. void CloseDownScreen( void );
  152. int OpenWPWindow( void );
  153. void CloseWPWindow( void );
  154. void OpenLibs(void);
  155. void CloseLibs(void);
  156. void ChooseScreenMode(void);
  157. void KillTestWindow(struct Window *, struct RastPort *, struct BitMap *);
  158. ULONG GetChecksum(struct Window *);
  159. void PrintScreenAttrs(struct Screen *);
  160. void showTestParams(int,int,int,int,int,ULONG, ULONG);
  161. void allocatePixelArray(struct Window *);
  162. void freePixelArray(void);
  163. void initPixelArray(void);
  164. void DoPlot(struct Window *, struct RastPort *, struct RastPort *);
  165. void DoTest(int,int,int,int,int);
  166. void showSelections(void);
  167. void QUIT(void);
  168. extern void KPrintF(STRPTR,...);
  169.  
  170. /*----------------------------------------------------------------------------
  171. ----------------------------------------------------------------------------*/
  172.  
  173.  
  174. /*----------------------------------------------------------------------------
  175.     OpenLibs() -
  176.         Input -
  177.             none
  178.         Function -
  179.             Opens all necessary disk and rom based libraries.
  180. ----------------------------------------------------------------------------*/
  181. void OpenLibs()
  182. {
  183.     if (! (IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0L))) {
  184.         dPrintf("Couldn't open intuition.library\n");
  185.         QUIT();
  186.     }
  187.     if (! (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",36L))) {
  188.         dPrintf("Couldn't open graphics.library\n");
  189.         QUIT();
  190.     }
  191.     if (! (GadToolsBase = (struct GadToolsBase *)OpenLibrary("gadtools.library",0L))) {
  192.         dPrintf("Couldn't open gadtools.library\n");
  193.         QUIT();
  194.     }
  195.     if (! (LayersBase = (struct LayersBase *)OpenLibrary("layers.library",0L))) {
  196.         dPrintf("Couldn't open layers.library\n");
  197.         QUIT();
  198.     }
  199. }
  200.  
  201.  
  202. /*----------------------------------------------------------------------------
  203.     CloseLibs()
  204.     Input -
  205.         none
  206.     Function -
  207.         Close all opened libraries.
  208. ----------------------------------------------------------------------------*/
  209. void CloseLibs()
  210. {
  211.     if (LayersBase ) {
  212.         CloseLibrary((struct Library *)LayersBase);
  213.     }
  214.     if (GadToolsBase) {
  215.         CloseLibrary((struct Library *)GadToolsBase);
  216.     }
  217.     if (GfxBase) {
  218.         CloseLibrary((struct Library *)GfxBase);
  219.     }
  220.     if (IntuitionBase) {
  221.         CloseLibrary((struct Library *)IntuitionBase);
  222.     }
  223. }
  224.  
  225.  
  226. /*----------------------------------------------------------------------------
  227.     dPrintf()
  228.     Input -
  229.         char *s
  230.     Function -
  231.         print a string to stdout and out the serial port
  232. ----------------------------------------------------------------------------*/
  233. void dPrintf(char *s)
  234. {
  235.     KPrintF("%s",s);
  236.     printf("%s",s);
  237. }
  238.  
  239.  
  240. /*----------------------------------------------------------------------------
  241.     ChooseScreenMode() -
  242.         Input -
  243.         Function -
  244.             Open an ASL screenmode requester to allow user to select screen mode
  245.             for the test.
  246. ----------------------------------------------------------------------------*/
  247. void ChooseScreenMode()
  248. {
  249.     if (!(smr = (struct ScreenModeRequester *)AllocAslRequestTags( ASL_ScreenModeRequest,
  250.         ASLSM_TitleText, "Choose Screen Mode",
  251.         TAG_DONE ))) {
  252.         dPrintf("Could not allocate asl request tags\n");
  253.         QUIT();
  254.     }
  255.     if (!(AslRequest(smr,0L))) {
  256.         dPrintf("No screen mode chosen - program aborted.\n");
  257.         FreeAslRequest(smr);
  258.         QUIT();
  259.     }
  260. }
  261.  
  262.  
  263. /*----------------------------------------------------------------------------
  264.     KillTestWindow() -
  265.         Input -
  266.             struct Window *wnd
  267.             struct RastPort *rp
  268.             struct BitMap *bm
  269.         Function -
  270.             Generic function that:
  271.                 Sets RastPort Write Mask to -1 (default)
  272.                 Frees memory allocated for bitmap planes
  273.                 Frees memory allocated for bitmap
  274.                 Frees memory allocated for rastport
  275.                 Closes window
  276. ----------------------------------------------------------------------------*/
  277. void KillTestWindow(struct Window *wnd,struct RastPort *rp, struct BitMap *bm)
  278. {
  279.     int i = 0;
  280.     LONG mask = -1;
  281.  
  282.     if (rp) {
  283.         SetWrMsk(rp, (ULONG)mask);
  284.     }
  285.     if (wnd) {
  286.         if (rp) {
  287.             rp->BitMap = NULL;
  288.             FreeMem(rp,sizeof(struct RastPort));
  289.         }
  290.         if (bm) {
  291.             for (i = 0; i < depth; i++) {
  292.                 if (bm->Planes[i]) {
  293.                     FreeRaster((PLANEPTR)bm->Planes[i],(ULONG)wnd->Width, (ULONG)wnd->Height);
  294.                 }
  295.          }
  296.             FreeMem(bm,sizeof(struct BitMap));
  297.         }
  298.        CloseWindow(wnd);
  299.     }
  300. }
  301.  
  302.  
  303. /*----------------------------------------------------------------------------
  304.     GetChecksum() -
  305.         Input -
  306.             struct Window *win
  307.         Function -
  308.             Calculates the checksum of all pixels in given window
  309. ----------------------------------------------------------------------------*/
  310. ULONG GetChecksum(struct Window *win)
  311. {
  312.     int x = 0;
  313.     int y = 0;
  314.     register ULONG checksum = 0;
  315.     register ULONG tmp = 0;
  316.     register ULONG tmp2 = 0;
  317.  
  318.     for (x = 0; x <= (win->Width); x++) {
  319.         for (y = 0; y <= (win->Height); y++) {
  320.             tmp = checksum << 1;
  321.             tmp2 = (checksum & 0x80000000) >> 31;
  322. /*            KPrintF("tmp = 0x%08lx,tmp2 = 0x%08lx\n",tmp,tmp2); */
  323.             checksum = tmp + tmp2 + (ULONG)ReadPixel(win->RPort,x,y);
  324.         }
  325.     }
  326.     return(checksum);
  327. }
  328.  
  329.  
  330. /*----------------------------------------------------------------------------
  331.     PrintScrAttrs() -
  332.         Input -
  333.             struct Screen *scr
  334.         Function -
  335.             Prints out info about given screen structure
  336. ----------------------------------------------------------------------------*/
  337. void PrintScrAttrs(struct Screen *scr)
  338. {
  339.     if (scr) {
  340.         printf("\tscr->LeftEdge   %ld\n",scr->LeftEdge);
  341.         KPrintF("\tscr->LeftEdge   %ld\n",scr->LeftEdge);
  342.         printf("\tscr->TopEdge    %ld\n",scr->TopEdge);
  343.         KPrintF("\tscr->TopEdge    %ld\n",scr->TopEdge);
  344.         printf("\tscr->Width      %ld\n",scr->Width);
  345.         KPrintF("\tscr->Width      %ld\n",scr->Width);
  346.         printf("\tscr->Height     %ld\n",scr->Height);
  347.         KPrintF("\tscr->Height     %ld\n",scr->Height);
  348.         printf("\tscr->Flags      %ld\n",scr->Flags);
  349.         KPrintF("\tscr->Flags      %ld\n",scr->Flags);
  350.         printf("\tscr->WBorTop    %ld\n",scr->WBorTop);
  351.         KPrintF("\tscr->WBorTop    %ld\n",scr->WBorTop);
  352.         printf("\tscr->WBorLeft   %ld\n",scr->WBorLeft);
  353.         KPrintF("\tscr->WBorLeft   %ld\n",scr->WBorLeft);
  354.         printf("\tscr->WBorRight  %ld\n",scr->WBorRight);
  355.         KPrintF("\tscr->WBorRight  %ld\n",scr->WBorRight);
  356.         printf("\tscr->WBorBottom %ld\n",scr->WBorBottom );
  357.         KPrintF("\tscr->WBorBottom %ld\n",scr->WBorBottom );
  358.     }
  359. }
  360.  
  361.  
  362. /*----------------------------------------------------------------------------
  363.     allocatePixelArray()
  364.         Function -
  365.             Allocates memory for the Pixel Array
  366. ----------------------------------------------------------------------------*/
  367. void allocatePixelArray(struct Window *win)
  368. {
  369.     pixelarraywidth = RangeRand(win->Width - 1) + 1;
  370.     pixelarrayheight = RangeRand(win->Height - 1) + 1;
  371.     KPrintF("\tpixelarraywidth = %ld, pixelarrayheight = %ld\n",pixelarraywidth,pixelarrayheight);
  372.     printf("\tpixelarraywidth = %ld, pixelarrayheight = %ld\n",pixelarraywidth,pixelarrayheight);
  373.     pixelarray = (UBYTE *)AllocMem(sizeof(long) * (((pixelarraywidth + 15) >> 4) << 4) * (pixelarrayheight + 1), MEMF_CHIP | MEMF_CLEAR);
  374.     if (! pixelarray) {
  375.         dPrintf("Couldn't allocate memory for pixelarray\n");
  376.         QUIT();
  377.     }
  378.  
  379.     initPixelArray();
  380. }
  381.  
  382.  
  383. /*----------------------------------------------------------------------------
  384.     freePixelArray
  385.         Function - free memory allocated for Pixel Array
  386. ----------------------------------------------------------------------------*/
  387. void freePixelArray()
  388. {
  389.     if (pixelarray) {
  390.         FreeMem(pixelarray, sizeof(long) * (((pixelarraywidth + 15) >> 4) << 4) * (pixelarrayheight + 1));
  391.         pixelarray = NULL;
  392.         pixelarraywidth = 0;
  393.         pixelarrayheight = 0;
  394.     }
  395. }
  396.  
  397.  
  398. /*----------------------------------------------------------------------------
  399.     initPixelArray()
  400.     Input -
  401.         UBYTE *pixelarray
  402.         int rectwidth
  403.         int rectheight
  404.     Function -
  405.         To initialize or re-initialize the pixel array for WritePixelArray8()
  406. ----------------------------------------------------------------------------*/
  407. void initPixelArray()
  408. {
  409.     int i = 0;
  410.     int k = 0;
  411.  
  412.     numbytes = ((((pixelarraywidth+15)>>4)<<4)*(pixelarrayheight + 1));
  413.     for (i = 0; i < numbytes; i++) {
  414.         k++;
  415.         if (k > 255) {
  416.             k = 0;
  417.         }
  418.         pixelarray[i] = k;
  419.     }
  420. }
  421.  
  422.  
  423. /*----------------------------------------------------------------------------
  424.     DoPlot() -
  425.         Input -
  426.             struct Window *win
  427.             struct RastPort *rp
  428.             struct RastPort *tmprp
  429. ----------------------------------------------------------------------------*/
  430. void DoPlot(struct Window *win, struct RastPort *rp, struct RastPort *tmprp) {
  431.     int count = 0;
  432.     int x = 0;
  433.     int y = 0;
  434.     int i = 0;
  435.     int numplots = 0;
  436.  
  437.     allocatePixelArray(win);
  438.  
  439.     /* Do Random plotting of the pixelarray */
  440.  
  441.     numplots = 1000;
  442.     for (i = 0; i < numplots; i++) {
  443.         x = RangeRand(win->Width);
  444.         y = RangeRand(win->Height);
  445.         if (((pixelarraywidth + x) < win->Width) && ((pixelarrayheight + y) < win->Height)) {
  446.             count = WritePixelArray8(rp, x, y, x + pixelarraywidth, y + pixelarrayheight, pixelarray, tmprp);
  447.             initPixelArray();
  448.         }
  449.     }
  450.  
  451.     freePixelArray();
  452. }
  453.  
  454.  
  455. /*----------------------------------------------------------------------------
  456.     showTestParams()
  457.         Input -
  458.             int depth
  459.             int layered
  460.             int refresh
  461.             int randomSize
  462.             int maskval
  463.             int wflags
  464.             ULONG Mask
  465. ----------------------------------------------------------------------------*/
  466. void showTestParams(int depth,int layered,int refresh,int randomSize,int maskval,ULONG wflags, ULONG Mask)
  467. {
  468.     dPrintf("Screen Attributes:\n");
  469.     PrintScrAttrs(TestScreen);
  470.  
  471.     KPrintF("%3ld> ", (LONG)depth);
  472.     printf("%3d> ", depth);
  473.  
  474.     switch (layered)
  475.     {
  476.         case 0:
  477.             dPrintf("Non-layered -- ");
  478.             break;
  479.         case 1:
  480.             dPrintf("Layered -- ");
  481.             break;
  482.         default:
  483.             break;
  484.     }
  485.     switch (refresh)
  486.     {
  487.         case 0:
  488.             dPrintf("Simple Refresh -- ");
  489.             wflags = wflags || WFLG_SIMPLE_REFRESH;
  490.             break;
  491.         case 1:
  492.             dPrintf("Smart Refresh -- ");
  493.             wflags = wflags || WFLG_SMART_REFRESH;
  494.             break;
  495.         case 2:
  496.             dPrintf("SuperBitMap -- ");
  497.             wflags = wflags || WFLG_SUPER_BITMAP;
  498.             break;
  499.         default:
  500.             break;
  501.     }
  502.     KPrintF("Mask value = 0x%lx\n",Mask);
  503.     printf("Mask value = 0x%lx\n",Mask);
  504. }
  505.  
  506.  
  507. /*----------------------------------------------------------------------------
  508.     DoTest() -
  509.     Input -
  510.         int depth
  511.         int layered
  512.         int refresh
  513.         int randomSize
  514.         int maskval
  515.     Function -
  516.         Collect all options and perform the test
  517. ----------------------------------------------------------------------------*/
  518. void DoTest(int depth,int layered,int refresh,int randomSize,int maskval)
  519. {
  520.     ULONG wflags = 0;
  521.     LONG Mask = 0;
  522.     int i = 0;
  523.     int k = 0;
  524.  
  525.     KPrintF("Display ID = 0x%08lx\n",(LONG)smr->sm_DisplayID);
  526.     printf("Display ID = 0x%08lx\n",smr->sm_DisplayID);
  527.  
  528.     /* Open Screen with depth of depth */
  529.     if (!(TestScreen = OpenScreenTags(NULL,
  530.         SA_DisplayID, (smr->sm_DisplayID),
  531.         SA_Depth, depth,
  532.         SA_ShowTitle, TRUE,
  533.         SA_Title, "WritePixelArray8 Test Screen",
  534.           TAG_END)))
  535.     {
  536.           dPrintf("Could not open test screen\n");
  537.         QUIT();
  538.     }
  539.  
  540.     switch (maskval) {
  541.         case 0:
  542.             Mask = RangeRand(255);
  543.             break;
  544.         case 1:
  545.             Mask = -1;
  546.             break;
  547.         default:
  548.             break;
  549.     }
  550.  
  551.     showTestParams(depth,layered,refresh,randomSize,maskval,wflags,Mask);
  552.  
  553.  
  554.     /* Open Windows on the screen */
  555.     for (i = 0; i < NUMWINS; i++) {
  556.         TestWins[i] = OpenWindowTags(NULL,
  557.             WA_Flags, wflags,
  558.             WA_Borderless, FALSE,
  559.             WA_CustomScreen, TestScreen,
  560.             WA_Top, RangeRand(TestScreen->Height),
  561.             WA_Left, RangeRand(TestScreen->Width),
  562.             WA_Width, RangeRand(TestScreen->Width) + 10,
  563.             WA_Height, RangeRand(TestScreen->Height) + 10,
  564.             WA_Title, "TestWindow",
  565.             TAG_END);
  566.         if (! TestWins[i]) {
  567.             KPrintF("Couldn't open test window %ld\n",i);
  568.             printf("Couldn't open test window %ld\n",i);
  569.         }
  570.         else {
  571.             RPs[i] = TestWins[i]->RPort;
  572.             SetWrMsk(RPs[i],Mask);
  573.             TempBMs[i] = (struct BitMap *)AllocMem(sizeof(struct BitMap), MEMF_CHIP || MEMF_CLEAR);
  574.             if    (! TempBMs[i]) {
  575.                 dPrintf("Couldn't allocate temporary bitmap\n");
  576.                 QUIT();
  577.             }
  578.             InitBitMap(TempBMs[i],depth,(LONG)TestWins[i]->Width,(LONG)TestWins[i]->Height);
  579.             TempRPs[i] = (struct RastPort *)AllocMem(sizeof(struct RastPort), MEMF_CHIP || MEMF_CLEAR);
  580.             if (! TempRPs[i]) {
  581.                 QUIT();
  582.             }
  583.             InitRastPort(TempRPs[i]);
  584.             /* copy RPs[i] info to TempRPs[i] */
  585.             TempRPs[i]->AreaPtrn = RPs[i]->AreaPtrn;
  586.             TempRPs[i]->AreaInfo = RPs[i]->AreaInfo;
  587.             TempRPs[i]->GelsInfo = RPs[i]->GelsInfo;
  588.             TempRPs[i]->Mask = RPs[i]->Mask;
  589.             TempRPs[i]->FgPen = RPs[i]->FgPen;
  590.             TempRPs[i]->BgPen = RPs[i]->BgPen;
  591.             TempRPs[i]->AOlPen = RPs[i]->AOlPen;
  592.             TempRPs[i]->DrawMode = RPs[i]->DrawMode;
  593.             TempRPs[i]->AreaPtSz = RPs[i]->AreaPtSz;
  594.             TempRPs[i]->linpatcnt = RPs[i]->linpatcnt;
  595.             TempRPs[i]->Flags = RPs[i]->Flags;
  596.             TempRPs[i]->LinePtrn = RPs[i]->LinePtrn;
  597.             TempRPs[i]->cp_x = RPs[i]->cp_x;
  598.             TempRPs[i]->cp_y = RPs[i]->cp_y;
  599.             TempRPs[i]->PenWidth = RPs[i]->PenWidth;
  600.             TempRPs[i]->PenHeight = RPs[i]->PenHeight;
  601.  
  602.             TempRPs[i]->BitMap = TempBMs[i];
  603.             TempRPs[i]->Layer = NULL;
  604.             TempRPs[i]->BitMap->BytesPerRow = numbytes;
  605.             for (k = 0; k < depth; k++) {
  606.                 TempBMs[i]->Planes[k] = NULL;
  607.             }
  608.             for (k = 0; k < depth; k++) {
  609.                 TempBMs[i]->Planes[k] = (PLANEPTR)AllocRaster((ULONG)TestWins[i]->Width, (ULONG)TestWins[i]->Height);
  610.                 if (!TempBMs[i]->Planes[k]) {
  611.                     KPrintF("Couldn't allocate plane for TempBMs[%ld]\n",i);
  612.                     printf("Couldn't allocate plane for TempBMs[%ld]\n",i);
  613.                     QUIT();
  614.                 }
  615.             }
  616.         }
  617.     }
  618.  
  619.  
  620.  
  621.  
  622.     /**************** Do plotting *******************/
  623.     for (i = 0; i < NUMWINS; i++) {
  624.         if (TestWins[i]) {
  625.             DoPlot(TestWins[i], RPs[i], TempRPs[i]);
  626.             PixCheckSum = GetChecksum(TestWins[i]);
  627.             KPrintF("\tChecksum for Window %ld = 0x%08lx\n",i,PixCheckSum);
  628.             printf("\tChecksum for Window %ld = 0x%08lx\n",i,PixCheckSum);
  629.             PixCheckSum = 0;
  630.         }
  631.     }
  632.  
  633.  
  634.  
  635.     /* Close all of the open windows and the screen */
  636.     dPrintf("Closing Windows...\n");
  637.     Delay(100);
  638.     for (i = 0; i < NUMWINS; i++) {
  639.         if (TestWins[i]) {
  640.             KillTestWindow(TestWins[i], TempRPs[i], TempBMs[i]);
  641.             TestWins[i] = NULL;
  642.             TempRPs[i] = NULL;
  643.             TempBMs[i] = NULL;
  644.             RPs[i] = NULL;
  645.         }
  646.     }
  647.  
  648.     if (TestScreen) {
  649.           CloseScreen(TestScreen);
  650.         TestScreen = NULL;
  651.    }
  652. }
  653.  
  654.  
  655.  
  656. /*----------------------------------------------------------------------------
  657.     QUIT() -
  658.     Input -
  659.         none
  660.     Function -
  661.         Deallocate screen mode requester
  662.         Close Screen
  663.         Close Libraries
  664. ----------------------------------------------------------------------------*/
  665. void QUIT()
  666. {
  667.     int i = 0;
  668.  
  669.     if (smr) {
  670.         FreeAslRequest(smr);
  671.     }
  672.  
  673.     for ( i = 0; i < NUMWINS; i++) {
  674.         if (TestWins[i]) {
  675.             KillTestWindow(TestWins[i], TempRPs[i], TempBMs[i]);
  676.             TestWins[i] = NULL;
  677.             TempRPs[i] = NULL;
  678.             TempBMs[i] = NULL;
  679.             RPs[i] = NULL;
  680.         }
  681.     }
  682.  
  683.     if (pixelarray) {
  684.         freePixelArray();
  685.     }
  686.  
  687.     if (TestScreen) {
  688.           CloseScreen(TestScreen);
  689.         TestScreen = NULL;
  690.    }
  691.     CloseLibs();
  692.  
  693.    exit(0);
  694. }
  695.  
  696.  
  697. /*----------------------------------------------------------------------------
  698.     ComputeX -
  699.     Input -
  700.         UWORD value
  701.     Function -
  702.         Calculate font sensitive X value
  703. ----------------------------------------------------------------------------*/
  704. static UWORD ComputeX( UWORD value )
  705. {
  706.     return(( UWORD )(( FontX * value ) / 8 ));
  707. }
  708.  
  709.  
  710. /*----------------------------------------------------------------------------
  711.     ComputeY -
  712.     Input -
  713.         UWORD value
  714.     Function -
  715.         Calculate font sensitive Y value
  716. ----------------------------------------------------------------------------*/
  717. static UWORD ComputeY( UWORD value )
  718. {
  719.     return(( UWORD )(( FontY * value ) / 8 ));
  720. }
  721.  
  722.  
  723. /*----------------------------------------------------------------------------
  724.     ComputeFont()
  725.     Input -
  726.         UWORD width
  727.         UWORD height
  728.     Function -
  729.         Select font for display
  730. ----------------------------------------------------------------------------*/
  731. static void ComputeFont( UWORD width, UWORD height )
  732. {
  733.     Font = &Attr;
  734.     Font->ta_Name = GfxBase->DefaultFont->tf_Message.mn_Node.ln_Name;
  735.     Font->ta_YSize = FontY = GfxBase->DefaultFont->tf_YSize;
  736.     FontX = GfxBase->DefaultFont->tf_XSize;
  737.  
  738.     OffY = Scr->Font->ta_YSize + Scr->WBorTop + 1;
  739.     OffX = Scr->WBorLeft;
  740.  
  741.     if ( width && height ) {
  742.         if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
  743.             goto UseTopaz;
  744.         if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
  745.             goto UseTopaz;
  746.     }
  747.     return;
  748.  
  749. UseTopaz:
  750.     Font->ta_Name = (STRPTR)"topaz.font";
  751.     FontX = FontY = Font->ta_YSize = 8;
  752. }
  753.  
  754.  
  755. /*----------------------------------------------------------------------------
  756.     SetupScreen() -
  757.     Input -
  758.         none
  759.     Function -
  760.         Lock the workbench screen in order to open initial options window
  761.         Choose display font
  762. ----------------------------------------------------------------------------*/
  763. int SetupScreen( void )
  764. {
  765.     if ( ! ( Scr = LockPubScreen((UBYTE * )"Workbench" ))) {
  766.        return( 1L );
  767.     }
  768.  
  769.     ComputeFont( 0L, 0L );
  770.  
  771.     if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE ))) {
  772.         return( 2L );
  773.     }
  774.     return( 0L );
  775. }
  776.  
  777.  
  778. /*----------------------------------------------------------------------------
  779.     CloseDownScreen() -
  780.         Input -
  781.             none
  782.         Function -
  783.             Unlock the workbench screen
  784. ----------------------------------------------------------------------------*/
  785. void CloseDownScreen( void )
  786. {
  787.     if ( VisualInfo ) {
  788.         FreeVisualInfo( VisualInfo );
  789.         VisualInfo = NULL;
  790.     }
  791.  
  792.     if ( Scr        ) {
  793.         UnlockPubScreen( NULL, Scr );
  794.         Scr = NULL;
  795.     }
  796. }
  797.  
  798.  
  799. /*----------------------------------------------------------------------------
  800.     OpenWPWindow()
  801.         Input -
  802.             none
  803.         Function -
  804.             Setup up gadtools gadgets and open the initial test options window
  805. ----------------------------------------------------------------------------*/
  806. int OpenWPWindow( void )
  807. {
  808.     struct NewGadget     ng;
  809.     struct Gadget       *g;
  810.     UWORD               wleft = WPLeft, wtop = WPTop, ww, wh;
  811.  
  812.     ComputeFont( WPWidth, WPHeight );
  813.  
  814.     ww = ComputeX( WPWidth );
  815.     wh = ComputeY( WPHeight );
  816.  
  817.     if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
  818.     if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
  819.  
  820.     if ( ! ( g = CreateContext( &WPGList )))
  821.         return( 1L );
  822.  
  823.     ng.ng_LeftEdge        =    OffX + ComputeX( 4 );
  824.     ng.ng_TopEdge         =    OffY + ComputeY( 5 );
  825.     ng.ng_Width           =    ComputeX( 45 );
  826.     ng.ng_Height          =    ComputeY( 18 );
  827.     ng.ng_GadgetText      =    NULL;
  828.     ng.ng_TextAttr        =    Font;
  829.     ng.ng_GadgetID        =    GD_Depth;
  830.     ng.ng_Flags           =    0;
  831.     ng.ng_VisualInfo      =    VisualInfo;
  832.  
  833.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Depth:", TAG_DONE );
  834.  
  835.     WPGadgets[ 0 ] = g;
  836.  
  837.     ng.ng_LeftEdge        =    OffX + ComputeX( 63 );
  838.     ng.ng_TopEdge         =    OffY + ComputeY( 6 );
  839.     ng.ng_GadgetText      =    (UBYTE *)"1";
  840.     ng.ng_GadgetID        =    GD_depth1;
  841.     ng.ng_Flags           =    PLACETEXT_BELOW;
  842.  
  843.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  844.  
  845.     WPGadgets[ 1 ] = g;
  846.  
  847.     ng.ng_LeftEdge        =    OffX + ComputeX( 90 );
  848.     ng.ng_GadgetText      =    (UBYTE *)"2";
  849.     ng.ng_GadgetID        =    GD_depth2;
  850.  
  851.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  852.  
  853.     WPGadgets[ 2 ] = g;
  854.  
  855.     ng.ng_LeftEdge        =    OffX + ComputeX( 117 );
  856.     ng.ng_GadgetText      =    (UBYTE *)"3";
  857.     ng.ng_GadgetID        =    GD_depth3;
  858.  
  859.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  860.  
  861.     WPGadgets[ 3 ] = g;
  862.  
  863.     ng.ng_LeftEdge        =    OffX + ComputeX( 144 );
  864.     ng.ng_GadgetText      =    (UBYTE *)"4";
  865.     ng.ng_GadgetID        =    GD_depth4;
  866.  
  867.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  868.  
  869.     WPGadgets[ 4 ] = g;
  870.  
  871.     ng.ng_LeftEdge        =    OffX + ComputeX( 171 );
  872.     ng.ng_GadgetText      =    (UBYTE *)"5";
  873.     ng.ng_GadgetID        =    GD_depth5;
  874.  
  875.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  876.  
  877.     WPGadgets[ 5 ] = g;
  878.  
  879.     ng.ng_LeftEdge        =    OffX + ComputeX( 198 );
  880.     ng.ng_GadgetText      =    (UBYTE *)"6";
  881.     ng.ng_GadgetID        =    GD_depth6;
  882.  
  883.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  884.  
  885.     WPGadgets[ 6 ] = g;
  886.  
  887.     ng.ng_LeftEdge        =    OffX + ComputeX( 225 );
  888.     ng.ng_GadgetText      =    (UBYTE *)"7";
  889.     ng.ng_GadgetID        =    GD_depth7;
  890.  
  891.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  892.  
  893.     WPGadgets[ 7 ] = g;
  894.  
  895.     ng.ng_LeftEdge        =    OffX + ComputeX( 252 );
  896.     ng.ng_GadgetText      =    (UBYTE *)"8";
  897.     ng.ng_GadgetID        =    GD_depth8;
  898.  
  899.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  900.  
  901.     WPGadgets[ 8 ] = g;
  902.  
  903.     ng.ng_LeftEdge        =    OffX + ComputeX( 79 );
  904.     ng.ng_TopEdge         =    OffY + ComputeY( 39 );
  905.     ng.ng_GadgetText      =    (UBYTE *)"Layered";
  906.     ng.ng_GadgetID        =    GD_layered;
  907.     ng.ng_Flags           =    PLACETEXT_RIGHT;
  908.  
  909.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  910.  
  911.     WPGadgets[ 9 ] = g;
  912.  
  913.     ng.ng_TopEdge         =    OffY + ComputeY( 51 );
  914.     ng.ng_GadgetText      =    (UBYTE *)"Non-Layered";
  915.     ng.ng_GadgetID        =    GD_nonlayered;
  916.  
  917.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  918.  
  919.     WPGadgets[ 10 ] = g;
  920.  
  921.     ng.ng_TopEdge         =    OffY + ComputeY( 74 );
  922.     ng.ng_GadgetText      =    (UBYTE *)"Simple Refresh";
  923.     ng.ng_GadgetID        =    GD_simple;
  924.  
  925.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  926.  
  927.     WPGadgets[ 11 ] = g;
  928.  
  929.     ng.ng_TopEdge         =    OffY + ComputeY( 86 );
  930.     ng.ng_GadgetText      =    (UBYTE *)"Smart Refresh";
  931.     ng.ng_GadgetID        =    GD_smart;
  932.  
  933.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  934.  
  935.     WPGadgets[ 12 ] = g;
  936.  
  937.     ng.ng_TopEdge         =    OffY + ComputeY( 98 );
  938.     ng.ng_GadgetText      =    (UBYTE *)"Super Refresh";
  939.     ng.ng_GadgetID        =    GD_super;
  940.  
  941.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  942.  
  943.     WPGadgets[ 13 ] = g;
  944.  
  945.     ng.ng_LeftEdge        =    OffX + ComputeX( 5 );
  946.     ng.ng_TopEdge         =    OffY + ComputeY( 35 );
  947.     ng.ng_Width           =    ComputeX( 45 );
  948.     ng.ng_Height          =    ComputeY( 18 );
  949.     ng.ng_GadgetText      =    NULL;
  950.     ng.ng_GadgetID        =    GD_lay;
  951.     ng.ng_Flags           =    0;
  952.  
  953.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Layered:", TAG_DONE );
  954.  
  955.     WPGadgets[ 14 ] = g;
  956.  
  957.     ng.ng_LeftEdge        =    OffX + ComputeX( 4 );
  958.     ng.ng_TopEdge         =    OffY + ComputeY( 71 );
  959.     ng.ng_GadgetID        =    GD_refresh;
  960.  
  961.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Refresh:", TAG_DONE );
  962.  
  963.     WPGadgets[ 15 ] = g;
  964.  
  965.     ng.ng_TopEdge         =    OffY + ComputeY( 115 );
  966.     ng.ng_GadgetID        =    GD_mask;
  967.  
  968.     g = CreateGadget( TEXT_KIND, g, &ng, GTTX_Text, "Mask:", TAG_DONE );
  969.  
  970.     WPGadgets[ 16 ] = g;
  971.  
  972.     ng.ng_LeftEdge        =    OffX + ComputeX( 79 );
  973.     ng.ng_TopEdge         =    OffY + ComputeY( 120 );
  974.     ng.ng_GadgetText      =    (UBYTE *)"Random Masks";
  975.     ng.ng_GadgetID        =    GD_ranmask;
  976.     ng.ng_Flags           =    PLACETEXT_RIGHT;
  977.  
  978.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  979.  
  980.     WPGadgets[ 17 ] = g;
  981.  
  982.     ng.ng_TopEdge         =    OffY + ComputeY( 132 );
  983.     ng.ng_GadgetText      =    (UBYTE *)"-1 Mask";
  984.     ng.ng_GadgetID        =    GD_negmask;
  985.  
  986.     g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, TRUE, TAG_DONE );
  987.  
  988. /*    WPGadgets[ 18 ] = g;
  989.  
  990.     ng.ng_LeftEdge        =    OffX + ComputeX( 240 );
  991.     ng.ng_TopEdge         =    OffY + ComputeY( 119 );
  992.     ng.ng_Width           =    ComputeX( 38 );
  993.     ng.ng_Height          =    ComputeY( 13 );
  994.     ng.ng_GadgetText      =    (UBYTE *)"#";
  995.     ng.ng_GadgetID        =    GD_nummasks;
  996.     ng.ng_Flags           =    PLACETEXT_LEFT;
  997.  
  998.     g = CreateGadget( STRING_KIND, g, &ng, GTST_String, "3", GTST_MaxChars, 3, TAG_DONE ); */
  999.  
  1000.     WPGadgets[ 18 ] = g;
  1001.  
  1002.     if ( ! g )
  1003.         return( 2L );
  1004.  
  1005.     if ( ! ( WPWnd = OpenWindowTags( NULL,
  1006.                     WA_Left,          wleft,
  1007.                     WA_Top,           wtop,
  1008.                     WA_Width,         ww + OffX + Scr->WBorRight,
  1009.                     WA_Height,        wh + OffY + Scr->WBorBottom,
  1010.                     WA_IDCMP,         TEXTIDCMP|CHECKBOXIDCMP|STRINGIDCMP|IDCMP_CLOSEWINDOW|IDCMP_REFRESHWINDOW,
  1011.                     WA_Flags,         WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_SMART_REFRESH|WFLG_ACTIVATE,
  1012.                     WA_Gadgets,       WPGList,
  1013.                     WA_Title,         WPWdt,
  1014.                     WA_ScreenTitle,   "WPixel",
  1015.                     TAG_DONE )))
  1016.         return( 4L );
  1017.  
  1018.     GT_RefreshWindow( WPWnd, NULL );
  1019.  
  1020.     return( 0L );
  1021. }
  1022.  
  1023.  
  1024. /*----------------------------------------------------------------------------
  1025.     handleWPIDCMP()
  1026.         Input -
  1027.             none
  1028.         Function -
  1029.             Handle the IDCMP event loop for the initial options window
  1030. ----------------------------------------------------------------------------*/
  1031. void handleWPIDCMP(void)
  1032. {
  1033.     struct IntuiMessage *imsg;
  1034.     struct Gadget *gad;
  1035.     int done = FALSE;
  1036.  
  1037.     while (!done)
  1038.     {
  1039.         Wait(1 << WPWnd->UserPort->mp_SigBit);
  1040.         while ((!done) && (imsg =
  1041.         GT_GetIMsg(WPWnd->UserPort)))
  1042.         {
  1043.             if (imsg != NULL)
  1044.             {
  1045.                 GT_ReplyIMsg(imsg);
  1046.                 switch(imsg->Class)
  1047.                 {
  1048.                     case IDCMP_CLOSEWINDOW:
  1049.                         done = TRUE;
  1050.                         break;
  1051.                     case IDCMP_GADGETUP:
  1052.                         gad = (struct Gadget *)imsg->IAddress;
  1053.                         switch(gad->GadgetID)
  1054.                         {
  1055.                             case GD_depth1:
  1056.                                 deptharray[0] = (deptharray[0] == FALSE) ? TRUE : FALSE;
  1057.                                 break;
  1058.                             case GD_depth2:
  1059.                                 deptharray[1] = (deptharray[1] == FALSE) ? TRUE : FALSE;
  1060.                                 break;
  1061.                             case GD_depth3:
  1062.                                 deptharray[2] = (deptharray[2] == FALSE) ? TRUE : FALSE;
  1063.                                 break;
  1064.                             case GD_depth4:
  1065.                                 deptharray[3] = (deptharray[3] == FALSE) ? TRUE : FALSE;
  1066.                                 break;
  1067.                             case GD_depth5:
  1068.                                 deptharray[4] = (deptharray[4] == FALSE) ? TRUE : FALSE;
  1069.                                 break;
  1070.                             case GD_depth6:
  1071.                                 deptharray[5] = (deptharray[5] == FALSE) ? TRUE : FALSE;
  1072.                                 break;
  1073.                             case GD_depth7:
  1074.                                 deptharray[6] = (deptharray[6] == FALSE) ? TRUE : FALSE;
  1075.                                 break;
  1076.                             case GD_depth8:
  1077.                                 deptharray[7] = (deptharray[7] == FALSE) ? TRUE : FALSE;
  1078.                                 break;
  1079.                             case GD_layered:
  1080.                                 layerarray[0] = (layerarray[0] == FALSE) ? TRUE : FALSE;
  1081.                                 break;
  1082.                             case GD_nonlayered:
  1083.                                 layerarray[1] = (layerarray[1] == FALSE) ? TRUE : FALSE;
  1084.                                 break;
  1085.                             case GD_simple:
  1086.                                 refresharray[0] = (refresharray[0] == FALSE) ?  TRUE : FALSE;
  1087.                                 break;
  1088.                             case GD_smart:
  1089.                                 refresharray[1] = (refresharray[1] == FALSE) ?  TRUE : FALSE;
  1090.                                 break;
  1091.                             case GD_super:
  1092.                                 refresharray[2] = (refresharray[2] == FALSE) ?  TRUE : FALSE;
  1093.                                 break;
  1094.                             case GD_ranmask:
  1095.                                 maskarray[0] = (maskarray[0] == FALSE) ? TRUE : FALSE;
  1096.                                 break;
  1097.                             case GD_negmask:
  1098.                                 maskarray[1] = (maskarray[1] == FALSE) ? TRUE : FALSE;
  1099.                                 break;
  1100. /*                            case GD_nummasks:
  1101.                                 break; */
  1102.                             default:
  1103.                                 break;
  1104.                         }
  1105.                        break;
  1106.                     case IDCMP_REFRESHWINDOW:
  1107.                         GT_BeginRefresh(WPWnd);
  1108.                         GT_EndRefresh(WPWnd,TRUE);
  1109.                         break;
  1110.                     default:
  1111.                         break;
  1112.                 }
  1113.             }
  1114.         }
  1115.     }
  1116. }
  1117.  
  1118.  
  1119. /*----------------------------------------------------------------------------
  1120.     CloseWPWindow()
  1121.     Input -
  1122.         none
  1123.     Function -
  1124.         Close the initial options window and free its gadgets
  1125. ----------------------------------------------------------------------------*/
  1126. void CloseWPWindow( void )
  1127. {
  1128.     if ( WPWnd        ) {
  1129.         CloseWindow( WPWnd );
  1130.         WPWnd = NULL;
  1131.     }
  1132.  
  1133.     if ( WPGList      ) {
  1134.         FreeGadgets( WPGList );
  1135.         WPGList = NULL;
  1136.     }
  1137. }
  1138.  
  1139.  
  1140. /*----------------------------------------------------------------------------
  1141.     showSelections()
  1142.     Input -
  1143.         none
  1144.     Function -
  1145.         Display user choices for test parameters
  1146. ----------------------------------------------------------------------------*/
  1147. void showSelections()
  1148. {
  1149.     int i = 0;
  1150.  
  1151.     /* print out results of user selections */
  1152.  
  1153.     dPrintf("\tdepths selected = ");
  1154.     for (i = 0; i < 8; i++) {
  1155.         if (deptharray[i]) {
  1156.             KPrintF("%ld ",i + 1);
  1157.             printf("%ld ",i + 1);
  1158.         }
  1159.     }
  1160.  
  1161.     dPrintf("\n\tLayer types selected = ");
  1162.     if (layerarray[0]) {
  1163.         dPrintf("Layered ");
  1164.     }
  1165.     if (layerarray[1]) {
  1166.         dPrintf("Non-layered ");
  1167.     }
  1168.  
  1169.     dPrintf("\n\tMasks selected = ");
  1170.     if (maskarray[0]) {
  1171.         dPrintf("Random ");
  1172.     }
  1173.     if (maskarray[1]) {
  1174.         dPrintf("-1 ");
  1175.     }
  1176.  
  1177.     dPrintf("\n\tRefresh modes selected = ");
  1178.     for (i = 0; i < 3; i++) {
  1179.         if (refresharray[i]) {
  1180.             switch(i) {
  1181.                 case 0:
  1182.                     dPrintf("Simple ");
  1183.                     break;
  1184.                 case 1:
  1185.                     dPrintf("Smart ");
  1186.                     break;
  1187.                 case 2:
  1188.                     dPrintf("Super ");
  1189.                     break;
  1190.                 default:
  1191.                     break;
  1192.             }
  1193.         }
  1194.     }
  1195.     dPrintf("\n");
  1196. }
  1197.  
  1198.  
  1199. /*----------------------------------------------------------------------------
  1200.     DoUserSelect()
  1201.     Input -
  1202.         none
  1203.     Function -
  1204.         Open the initial options window, get the options, and then display them.
  1205. ----------------------------------------------------------------------------*/
  1206. void DoUserSelect(void)
  1207. {
  1208.     SetupScreen();
  1209.     OpenWPWindow();
  1210.     handleWPIDCMP();
  1211.     CloseWPWindow();
  1212.     CloseDownScreen();
  1213. }
  1214.  
  1215.  
  1216. /*----------------------------------------------------------------------------
  1217.     DoAll()
  1218.     Input -
  1219.         none
  1220.     Function -
  1221.         Setup up test options so that all choices are picked.
  1222.         Display the options chosen.
  1223. ----------------------------------------------------------------------------*/
  1224. void DoAll(void)
  1225. {
  1226.     int i = 0;
  1227.  
  1228.     for (i = 0; i < 8; i++) {
  1229.         deptharray[i] = TRUE;
  1230.     }
  1231.     for (i = 0; i < 2; i++) {
  1232.         layerarray[i] = TRUE;
  1233.     }
  1234.     for (i = 0; i < 3; i++) {
  1235.         refresharray[i] = TRUE;
  1236.     }
  1237.     for (i = 0; i < 2; i++) {
  1238.         maskarray[i] = TRUE;
  1239.     }
  1240. }
  1241.  
  1242.  
  1243. /*----------------------------------------------------------------------------
  1244. ==============================================================================
  1245.     main()
  1246.         Input -
  1247.             int argc
  1248.             char **argv
  1249.         Function -
  1250.             main entry point
  1251. ==============================================================================
  1252. ----------------------------------------------------------------------------*/
  1253. void main(int argc, char **argv)
  1254. {
  1255.     int layered = 0;
  1256.     int refresh = 0;
  1257.     int randomSize = 0;
  1258.     int maskval = 0;
  1259.  
  1260.     OpenLibs();
  1261.  
  1262.  
  1263.     dPrintf("\n *** wpixel v2.1 - WritePixelArray8 test ***\n");
  1264.  
  1265.     if (argc >= 2) {
  1266.         if (0 == strcmp(argv[1],"all")) {
  1267.             DoAll();
  1268.         }
  1269.     }
  1270.     else {
  1271.         DoUserSelect();
  1272.     }
  1273.  
  1274.     showSelections();
  1275.     ChooseScreenMode();
  1276.  
  1277.     /* The 'tie up the machine' test */
  1278.     for (depth = 1; depth <= 8; depth++) {
  1279.         for (layered = 0; layered < 2; layered++) {
  1280.             for (refresh = 0; refresh < NUMREFRESH; refresh++) {
  1281.                 for (maskval = 0; maskval < 2; maskval++) {
  1282.                     if ((deptharray[depth - 1]) && (layerarray[layered]) && (refresharray[refresh]) && (maskarray[maskval])) {
  1283.                         NumTests++;
  1284.                         DoTest(depth, layered, refresh, randomSize, maskval);
  1285.                     }
  1286.                 }
  1287.             }
  1288.         }
  1289.     }
  1290.  
  1291.     KPrintF("total tests = %ld\n", (LONG)NumTests);
  1292.     printf("total tests = %ld\n", (LONG)NumTests);
  1293.  
  1294.     QUIT();
  1295. }